<template>
  <div>shallowReactive && shallowRef</div>
  <h1>{{ m1 }}</h1>
  <h1>{{ m2 }}</h1>
  <h1>{{ m3 }}</h1>
  <h1>{{ m4 }}</h1>
  <button @click="update">更新数据</button>
</template>

<script lang="ts">
import {defineComponent, reactive, shallowReactive, ref, shallowRef} from 'vue';

export default defineComponent({
  name: 'App',
  components: {},
  setup() {
    const m1 = reactive({
      name: 'm1',
      car: {
        name: 'm1Car'
      }
    })
    const m2 = shallowReactive({
      name: 'm2',
      car: {
        name: 'm2Car'
      }
    });
    const m3 = ref({
      name: 'm3',
      car: {
        name: 'm3Car'
      }
    })
    const m4 = shallowRef({
      name: 'm4',
      car: {
        name: 'm4Car'
      }
    })

    const update = () => {
      // m1.name +='###'
      // m1.car.name+='@@@@'
      // m2.name +='###'
      // m2.car.name+='@@@@'
      // m3.value.name +='###'
      // m3.value.car.name+='@@@@'
      // m4.value.name +='###'
      m4.value.car.name+='@@@@'
    }
    return {
      m1, m2, m3, m4, update
    }
  }
});
</script>

<style>

</style>
